package cn.wolfcode.wolf2w.util;

import cn.wolfcode.wolf2w.exception.LogicException;
import org.springframework.util.StringUtils;

public class AssertUtil {

    /**
     * 判断指定val是否有值,如果没有则抛出异常信息
     * @param val
     * @param msg
     */
    public static void hasLength(String val,String msg){
        if (!StringUtils.hasLength(val)){
            throw new LogicException(msg);
        }
    }

    /**
     * 判断两个值是否相等
     * @param val1
     * @param val2
     * @param msg
     */
    public static void isEquals(String val1,String val2,String msg){

        if(val1 == null || val2 == null){
            throw new LogicException("输入参数不能为空");
        }

        if (!val1.equals(val2)){
            throw new LogicException(msg);
        }
    }
}
